When executing managed code in a virtual machine (VM) environment, a user application program can run on different platforms. In such VM environments, native resources are typically allocated using system calls. These system calls can be made by libraries when executing code in the VM environment. These libraries commonly call through to the native operating system to perform low level functionality such as drawing and windowing management. When these system calls are made, native resources get allocated as an effect of the library call. These native resources must be kept in synchronization with their counterpart in the managed code portion of the VM. When the managed code portion of the VM is through using the native resource, it must then be freed.
Current techniques for exposing user interface (UI) and other libraries with associated underlying resources in a VM environment require a substantial amount of overhead when marshalling the data necessary to create, maintain synchronization, and destroy UI resources such as those that are involved in drawing and windowing management. In many computer-based application programs, a new UI resource is produced each time a new UI resource object is created. Often, developers can inadvertently neglect the effects on the processor speed of producing a large number of UI resources in application programs.
Managing each UI resource generates system calls across a VM/native boundary between the managed code portion and the native code portion. System calls across this VM/native boundary demand considerable processor effort due to the varied code translations that may be necessary for virtual machines to comply with different computer platforms and languages, as well as the considerable amount of data that precisely describes each UI resource. Garbage collection routines that remove managed UI resources also require significant processing since each of many UI resources has to be consciously removed individually, or alternately the UI resources are removed after some prescribed period. If the UI resources are removed after some prescribed period, then there may be a considerable number of UI resources waiting for the duration of the prescribed period to be removed. Storing such a considerable number of UI resources may make such tasks as drawing and windowing management slow in application programs that require corresponding UI resources. Additionally, present computer application programs typically produce multiple concurrently-saved copies of the UI resource. For example, as the UI resource is transferred between the VM, the native environment, and the operating system (OS) itself, a copy of each UI resource object is stored in memory associated with each location.
Application programs that run on such computer environments as stand alone computers, networked computer environments, and computer devices typically inefficiently manage such UI resources, but such inefficiency is typically ignored due to the large processing abilities of these computer environments. Smaller and less powerful, memory constrained and processor constrained devices (i.e. resource constrained devices) such as personal digital assistants (PDAs), cellular telephones, computer devices, embedded devices, microprocessor devices, and microcomputer devices are becoming increasingly popular. Resource constrained devices rely on more limited software, processors, memory, and operating systems than those applied to full size computer environments. Applying a large number of system calls to resource constrained devices commonly makes the devices prohibitively slow to perform many application functions. The code transitions necessary for system calls in resource constrained devices that have been produced between the native code portion and the managed code portion in virtual machines (especially for demanding application programs that require extensive use of UI resources) are so processor intensive that the processor and memory resources become significantly strained. A large amount of calls across the boundary between the managed code executing in the VM environment and the native code executing in the native environment results in undesirable performance characteristics. With respect to these difficult and repetitive calls across the native/managed code boundary that are needed to create and maintain UI resources, it would be an advantage in the art to avoid or reduce the number of calls across the VM/native boundary, particularly in resource constrained systems. Consequently, there is a need for improved methods, apparatuses, and computer readable medium that can provide such a capability.